package com.chb.test.getOddNumDemo_13;

public class MyThread extends Thread {
    static int num = 100;

    public MyThread() {
    }

    public MyThread(String name) {
        super(name);
    }

    @Override
    public void run() {
        while (true) {
            synchronized (MyThread.class) {
                if(num == 0) {
                    break;
                } else {
                    if(num % 2 != 0) {
                        System.out.println(getName() + "打印奇数：" + num);
                    }
                    num --;
                }

            }
        }
    }
}
